﻿<div class="chart-container" style="display: none; width: 688px; height: 360px; border: 2px solid #cccccc"></div>
<script type="text/javascript">
var dom = document.getElementsByClassName("chart-container")[0];var myChart = echarts.init(dom);var app = {};option = null;option = {
    textStyle: {
        fontFamily: 'microsoft yahei',
    },
    color: ['#f1c1ac','#add7a9', '#4285f4', '#d48265', '#91c7ae','#749f83',  '#ca8622', '#bda29a','#6e7074', '#546570', '#c4ccd3'],
    title : {
    	show: true,
        text: '各网站每周裸车均价',
        textStyle: {
            fontSize: 14,
        },
		left: 'center'
    },
    backgroundColor: '#fff',
	grid: {
		show: true,
		containLabel: true,
		bottom: 15,
        top: 60,
        left: 25,
        right: 25
	},
    tooltip : {
        trigger: 'axis',
        formatter: function (params) {
            var num = params.length;
            for (var i = 0; i < num; i++) {
            	if (params[i].seriesName == "汽车之家")
            		params[i].color = "#f1c1ac";
            	else if (params[i].seriesName == "易车网")
            		params[i].color = "#add7a9";
            	else if (params[i].seriesName == "车享商城")
            		params[i].color = "#4285f4";
            	else
            		params[i].color = "#000";
            }
            function mySort(a, b) {
                return (b.data > 0 ? b.data : -1) - (a.data > 0 ? a.data : -1);
            }
            params.sort(mySort);
            // for (var i = 0; i < num; i++) {
            //     console.log("seriesName: " + params[i].seriesName);
            //     console.log("name: " + params[i].name);
            //     console.log("dataIndex: " + params[i].dataIndex);
            //     console.log("data: " + params[i].data);
            //     console.log("/////////////////////////");
            // }
            var returnStr = params[0].name;
            for (var i = 0; i < num; i++) {
                if (params[i].data == '' || params[i].data == undefined) {
                    continue;
                    params[i].data = "-";
                }
                returnStr += "<br><span style=\"color:" + params[i].color + "\">" + params[i].seriesName + ":" + params[i].data + "</span>";
        	}
        	return returnStr;
    	},
		show: false,
		showContent: true,
        backgroundColor: 'rgba(255,255,255,0.8)',
        borderColor: '#333',
        borderWidth: 2,
        textStyle: {
            color: '#333',
        },
    },
    legend: {
        data:[
        	'汽车之家'
        	,'易车网'
        	,'车享商城'
        ],
		top: 25,
    },
    toolbox: {
        show : false,
        feature : {
            dataZoom: {},
            dataView: {readOnly: false},
            magicType: {type: ['line', 'bar']},
            restore: {},
            saveAsImage: {}
        }
    },
    xAxis : [
        {
            type : 'category',
            boundaryGap : true,
            data : [
					'5月9日'
					,'5月16日'
					,'5月23日'
					,'5月30日'
					,'6月6日'
			],
			axisLabel: {interval: 0, rotate: 0},
			splitLine: {interval: 0},
			splitArea: {show: false},
        }
    ],
    yAxis : [
        {
            type : 'value',
			name: '价格（万元）',
            nameGap: 10,
			scale: true
        }
    ],
    series : [
        {
            name:'汽车之家',
            type:'line',
            lineStyle: {
                normal: {
                type: 'dashed'
                }
            },
            smooth: true,
            data:[
					'13.16'
					,'13.15'
					,'13.10'
					,'13.20'
					,'13.26'
			]
        },
        {
            name:'易车网',
            type:'line',
            lineStyle: {
                normal: {
                type: 'dashed'
                }
            },
            smooth: true,
            data:[
					'12.93'
					,'13.13'
					,'13.12'
					,'12.89'
					,'12.86'
			]
        },
        {
            name:'车享商城',
            type:'line',
            smooth: true,
            data:[
					'11.59'
					,'11.59'
					,'11.59'
					,'11.59'
					,'11.39'
			]
        }
    ]
};
myChart.setOption(option);
</script>